/**
 * output package name
 */
package com.kingdee.eas.custom.hr.compensation.client;

import java.sql.Timestamp;
import java.util.Date;

import org.apache.log4j.Logger;

import com.kingdee.bos.ctrl.kdf.table.event.KDTMouseEvent;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.bos.metadata.entity.FilterItemInfo;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.bos.util.BOSUuid;
import com.kingdee.eas.basedata.person.PersonInfo;
import com.kingdee.eas.common.client.SysContext;
import com.kingdee.eas.custom.hr.compensation.AllowanceApplyFactory;
import com.kingdee.eas.hr.base.ApproveTypeEnum;
import com.kingdee.eas.hr.base.client.IHRBillListUIBiz;

/**
 * output class name
 */
public class AllowanceApplyListUI extends AbstractAllowanceApplyListUI
{
    private static final Logger logger = CoreUIObject.getLogger(AllowanceApplyListUI.class);
    
    /**
     * output class constructor
     */
    public AllowanceApplyListUI() throws Exception
    {
        super();
    }
    
    @Override
    protected void tblMain_tableClicked(KDTMouseEvent e) throws Exception {
    	// TODO Auto-generated method stub
    	super.tblMain_tableClicked(e);
    }
    
    /**
     * output getBizInterface method
     */
    protected com.kingdee.eas.framework.ICoreBase getBizInterface() throws Exception
    {
        return AllowanceApplyFactory.getRemoteInstance();
    }

    /**
     * output createNewData method
     */
    protected com.kingdee.bos.dao.IObjectValue createNewData()
    {
        com.kingdee.eas.custom.hr.compensation.AllowanceApplyInfo objectValue = 
        	new com.kingdee.eas.custom.hr.compensation.AllowanceApplyInfo();
        objectValue.setApproveType( ApproveTypeEnum.WORKFLOW );
        objectValue.setCreator((com.kingdee.eas.base.permission.UserInfo)(com.kingdee.eas.common.client.SysContext.getSysContext().getCurrentUser()));
        objectValue.setCreateTime(new Timestamp(System.currentTimeMillis()));
		objectValue.setHrOrgUnit(SysContext.getSysContext().getCurrentHRUnit());
		PersonInfo person = SysContext.getSysContext().getCurrentUserInfo().getPerson();
		objectValue.setAdminOrg(person.getDept());
        return objectValue;
    }


	@Override
	protected IHRBillListUIBiz getBillBiz() {
		return null;
	}

	
	@Override
	protected String getApproveTypeFieldName() {
		return "approveType";
	}

	@Override
	protected String getBillStateFieldName() {
		return "billState";
	}
	
	
	@Override
	protected FilterInfo getDefaultFilter() throws Exception {
		FilterInfo filter = super.getDefaultFilter();
		if (filter == null)
			filter = new FilterInfo();
		FilterInfo otherFilter = com.kingdee.eas.framework.FrameWorkUtils
				.getF7FilterInfoByAuthorizedOrg(
						com.kingdee.eas.basedata.org.OrgType.getEnum("Admin"),
						"adminOrg.id", true);
		if (otherFilter != null) {
			for (int i = 0, n = otherFilter.getFilterItems().size(); i < n; i++) {
				FilterItemInfo curFilterItem = otherFilter.getFilterItems()
						.get(i);
				if (curFilterItem.getCompareValue() != null
						&& (curFilterItem.getCompareValue() instanceof String)) {
					if ("*".equalsIgnoreCase((String) (curFilterItem
							.getCompareValue()))) {
						BOSUuid nullUuid = BOSUuid.create("nullnull");
						curFilterItem.setCompareValue(nullUuid.toString());
					}
				}
			}
			try {
				if (com.kingdee.eas.framework.util.FilterUtility
						.hasFilterItem(filter))
					filter.mergeFilter(otherFilter, "AND");
				else
					filter = otherFilter;
			} catch (Exception e) {
				this.handUIException(e);
			}
		}
		return filter;
	}
	
	
}